﻿
Partial Class loginPage
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If Request.IsAuthenticated Then
            Response.Redirect("home.aspx")
        End If

        nope.Visible = False
    End Sub


    Protected Sub login_LinkButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles login_LinkButton.Click


        Dim myUser As MembershipUser = Membership.GetUser(username_input.Text)

        
        If Not myUser Is Nothing Then
            If myUser.IsApproved = False Then
                Dim myGuid As Guid = myUser.ProviderUserKey
                Session.Add("userID", myGuid)
                Server.Transfer("notauthenticated.aspx?user=" & username_input.Text)
                Exit Sub
            elseif Membership.ValidateUser(username_input.Text, password_input.Text) Then
                nope.Visible = False
                FormsAuthentication.RedirectFromLoginPage(username_input.Text, False)
                Exit Sub
            ElseIf Not Membership.ValidateUser(username_input.Text, password_input.Text) Then
                nope.Visible = True
            End If
            nope.Visible = True
        End If


    End Sub
End Class
